﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace SynoManager.FileStation.Tasks
{
    public class UploadTask : TaskBase
    {
        private readonly string localPath;
        private readonly DirectoryInfo remotePath;
        private bool overwrite = true;

        public UploadTask(string localPath, DirectoryInfo remotePath)
        {
            this.localPath = localPath;
            this.remotePath = remotePath;
        }

        private static int trackingNumber = 1;
        public override void Execute()
        {
            Debug.WriteLine("Uploading " + localPath + " to " + remotePath.RelativePath, "UploadTask");

            int uploadNumber = UploadTask.trackingNumber++;

            FileStationClient client = Queue.Service.client;
            DateTime timestamp = DateTime.Now;

            client.Upload(remotePath.RelativePath, localPath, overwrite);

            OnCompleted();
        }

        public override string DisplayTitle
        {
            get { return "Upload " + System.IO.Path.GetFileName(localPath); }
        }

        public override string DisplayDescription
        {
            get { return "To " + remotePath.RelativePath; }
        }

        public override System.Drawing.Image DisplayImage
        {
            get { return Properties.Resources.page_white_get; }
        }
    }
}
